<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<!-- 主体内容 -->
<div id="excel-wrapper" class="container">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-primary">
                <div id="function-module-name" class="panel-heading">添加排期</div>
                <div class="panel-body">
                    <div id="addschedule-container">

                    </div>
                    <div id="excel-container">

                    </div>
                </div>
            </div>
            <button id="btn-reset" class="btn btn-danger" data-toggle="modal" >重置</button>
            <button id="btn-save" class="btn btn-danger" data-toggle="modal" data-target="#save-confirm">添加</button>

            <!--          <button id="dump">dump console</button>-->
        </div>
        <div class="col-md-3">
            <div class="panel panel-primary">
                <div  class="panel-heading">管理列表</div>
                <div class="panel-body">
                    <!--      列表信息--> 
                    <ul id="sheet-list" class="nav nav-pills nav-stacked">
                        <li id="btn-add-schedule"><a href="#">添加排期</a></li>
                        <li id="btn-alter-schedule" ><a href="#">修改排期</a></li>
                        <li id="btn-emp-management" ><a href="#">人员管理</a></li>

                    </ul>
                    <!-- <button id="btn-create-sheet" class="btn btn-default btn-sm">添加排期</button>
                    -->

                </div>
            </div>
        </div>
    </div>

</div>


<!--弹出框-->
<!--<button class="btn btn-primary"  id="myModal" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
     
    </div>
  </div>
</div>-->


<!--<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">排期详情</h4>
            </div>
            <div class="modal-body">
                <div id="modal-body-context"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                </div>


            </div>
        </div>
    </div>
</div>-->
<script type="text/javascript" charset="utf-8">


    function buildaddschedule() {
        //$('#addschedule-container').append(' <h3> <span class="label label-default">项目：</span></h3>');
        $('#addschedule-container').append(' <div class="input-group"><span class="input-group-addon">项目</span><input id="project" type="text" class="form-control" placeholder="不超过8个字哦"></div>');
        $('#addschedule-container').append(' <div class="input-group"><span class="input-group-addon">模块</span><input id="module" type="text" class="form-control" placeholder="不超过8个字哦"></div>');
        $('#addschedule-container').append(' <div class="input-group"><span class="input-group-addon">功能</span><input id="function" type="text" class="form-control" placeholder="不超过8个字哦"></div>');
        $('#addschedule-container').append(' <div class="input-group"><span class="input-group-addon">详情</span><input id="detail" type="text" class="form-control" placeholder="随便输入"></div>');
        $('#addschedule-container').append(' <div class="input-group"><span class="input-group-addon">人员</span><input id="people" type="text" class="form-control" placeholder="一个负责人就OK"></div>');
        // $('#addschedule-container').append(' <div class="input-group input-append date form_datetime" id="time-div" ><span class="input-group-addon">时间</span><input id="time" class="form-control" type="text" ><span class="add-on"><i class="icon-th"></i></span></div>');
        $('#addschedule-container').append('  <div class="input-group"><span class="input-group-addon">时间</span> <input type="text"  id="datetimepicker" class="form-control" data-date-format="yyyy-mm-dd"></div>');

    }
    //初始化
    $(function() {

        buildaddschedule();//创建添加排期的页面
        $('#datetimepicker').datetimepicker({
            minView: 'month',
            autoclose: true});
        //响应点击列表项内容


        $(document).on('click', '#sheet-list li', function(e) {  //查

            var $target = $(e.target);
            $('#sheet-list li').each(function() {
                $(this).removeClass('active');
            });
            $target.parent().addClass('active');

            $("#function-module-name").html($target.html());
        });

        $("#btn-reset").on('click', function() {  //增、改

            $("#project").val("");
            $("#module").val("");
            $("#function").val("");
            $("#detail").val("");
            $("#people").val("");
            $("#datetimepicker").val("");

        });
        $("#btn-save").on('click', function() {  //增、改
            // currentSheetContent = handsontable.getData();
            project = $("#project").val();

            module = $("#module").val();
            func = $("#function").val();
            detail = $("#detail").val();
            people = $("#people").val();
            dateline = $("#datetimepicker").val();
//            if(project==""||module==""||func==""||detail==""||people==""||dateline==""){
//                
//            }
//            alert(time);
//            alert(project+module+func+detail+people+time);
            $.ajax({
                type: "post",
                url: "/testdrive/index.php/schedule/addschedule",
                data: {"project": project,
                    "module": module,
                    "func": func,
                    "detail": detail,
                    "people": people,
                    "dateline": dateline},
                success: function(result) {
                    //  alert(result);
//                    alert(JSON.stringify(result));
                    $('#main-show-modal').modal({
                        keyboard: false
                    });
//$("#myModalLabel").html("添加排期");
                    $("#main-show-modal-body-context").html("添加成功！");
                    $("#project").val("");
                    $("#module").val("");
                    $("#function").val("");
                    $("#detail").val("");
                    $("#people").val("");
                    $("#datetimepicker").val("");


                    //alert("保存成功！");
                    if (result != null) {
                        //   alert(result.toString()+"恭喜，保存成功！");
                        // alert( result.toJSONString());

                    } else {
                        alert("不好意思，保存失败喽....");
                    }
                    //    var results = JSON.parse(result);


                },
                error: function() {
                    alert("保存失败！再尝试一下....");
                }
            }
            );

        });




    }
    );
   
</script>
